package com.manager
{
	import com.model.CarDataBase;
	import com.object3D.BaseCar;
	import com.object3D.NewBaseCar;
	import com.object3D.car.AudiR8;
	import com.vo.CarVo;
	import com.vo.PartVo;
	
	import flash.utils.Dictionary;

	public class CarManager
	{
		private static var nowCar:NewBaseCar;
		
		private static var carDic:Dictionary;
		public static function showCar(cvo:CarVo):void
		{
			if(nowCar != null){
				nowCar.hide();
			}
			createCar(cvo);
		}
		
		private static function createCar(cvo:CarVo):void
		{
			if(carDic == null)carDic = new Dictionary(true);
			if(carDic[cvo] === undefined){
				if(cvo.eName == 'AudiR8')
				{
					carDic[cvo] = new AudiR8();
				}
				else
				{
					carDic[cvo] = new NewBaseCar();
				}
			}
			nowCar = carDic[cvo];
			nowCar.show(cvo);
//			CarMaterial.changeColor();
		}		
		/**
		 * 
		 * @param sectionId 部件索引值 轮胎2
		 * @param path
		 */		
		public static function replace(pvo:PartVo):void
		{
			var sectionId:int = pvo.sectionID;
			if(sectionId == 2)
			{
				nowCar.replaceWheel(pvo);
				CarMaterial.weelColor(Math.random() * 0xFFFFFF);
			}
		}
		
	}
}